package com.xm_jd.controller.goods;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xm_jd.model.dao.NewDao;
import com.xm_jd.model.dao.PJDao;
import com.xm_jd.model.entitys.PjVO;
import com.xm_jd.utils.BaseServlet;

/**
 * Servlet implementation class xq_spj
 */
@WebServlet("/xq_spj")
public class xq_spj extends BaseServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public xq_spj() {
		super();
		// TODO Auto-generated constructor stub
	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		String spid = request.getParameter("spid");
		int id = Integer.parseInt(spid);
		// 查询所有的该商品的评论，根据商品编号
		List<PjVO> pj = new PJDao().getselectPj(id);
		// 查询该商品销售属性
		List<PjVO> xssx = new PJDao().getselectXssxz(id);

		if (pj.size() > 0) {
			request.setAttribute("pj", pj);
			request.setAttribute("xssx", xssx);
		}

		//request.getRequestDispatcher("jsps/pj/xq_pj.jsp").forward(request, response);
		this.forward("pj/xq_pj");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
